/*
 * Copyright (c) 2024 endless-sky
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef BASE_INCLUDE_BASE_MSG_H
#define BASE_INCLUDE_BASE_MSG_H

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief 等待消息
 * @param msg 要等待的消息字符串
 * @param timeout_ms 超时时间(毫秒)，如果为0则永久等待
 * @return 0表示成功收到消息，-1表示超时，-2表示参数错误
 */
int base_wait_message(const char *msg, int timeout_ms);

/**
 * @brief 发送消息
 * @param msg 要发送的消息字符串
 * @return 0表示发送成功，-1表示发送失败，-2表示参数错误
 */
int base_send_message(const char *msg);

#ifdef __cplusplus
}
#endif

#endif // BASE_INCLUDE_BASE_MSG_H